﻿#region

using System.Collections.Generic;
using System.Web.Mvc;
using System.Web.Routing;
using CuongHanh.Configuration;
using CuongHanh.Models.NotMapDB;

#endregion

namespace CuongHanh
{
    public class RouteConfig
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            MapRouteForGem(routes);
            MapRouteForCustomer(routes);
            MapRouteForCart(routes);
            MapRouteForWood(routes);
            MapRouteForStone(routes);

           

            routes.MapRoute(
                            "administrator",
                    "administrator",
                    new
                    {
                            controller = "AHome",
                            action = "Index",
                    }
                    );
            routes.MapRoute(
                          "gem-static-page",
                  "gt-ht-cskh/{name}-{id}",
                  new
                  {
                      controller = "StaticPage",
                      action = "Index",
                      id = UrlParameter.Optional
                  }
                  );
            routes.MapRoute(
                            name: "Default",
                    url: "{controller}/{action}/{id}",
                    defaults: new
                              {
                                      controller = "Wood",
                                      action = "Index",
                                      id = UrlParameter.Optional
                              }
                    );
        }

        private static void MapRouteForCustomer(RouteCollection routes)
        {
            List<RouteModel> models = new List<RouteModel>()
                                      {
                                              new RouteModel
                                              {
                                                      Name = "customer-login",
                                                      UrlVi = LinkConfig.DANG_NHAP,
                                                      UrlEn = "login",
                                                      Controller = "Customer",
                                                      Action = "Login"
                                              },
                                              new RouteModel
                                              {
                                                      Name = "customer-register",
                                                      UrlVi = LinkConfig.DANG_KY,
                                                      UrlEn = "register",
                                                      Controller = "Customer",
                                                      Action = "Register"
                                              },
                                              new RouteModel
                                              {
                                                      Name = "customer-forgot-password",
                                                      UrlVi = LinkConfig.QUEN_MAT_KHAU,
                                                      UrlEn = "forgot-password",
                                                      Controller = "Customer",
                                                      Action = "ForgotPassword"
                                              },
                                              new RouteModel
                                              {
                                                      Name = "customer-change-password-by-forgot",
                                                      UrlVi = LinkConfig.LAY_LAI_MAT_KHAU,
                                                      UrlEn = "change-password-by-forgot",
                                                      Controller = "Customer",
                                                      Action = "ChangePasswordByForgot"
                                              },
                                              new RouteModel
                                              {
                                                      Name = "customer-change-password",
                                                      UrlVi = LinkConfig.DOI_MAT_KHAU,
                                                      UrlEn = "change-password",
                                                      Controller = "Customer",
                                                      Action = "ChangePassword"
                                              },
                                              new RouteModel
                                              {
                                                      Name = "customer-log-off",
                                                      UrlVi = LinkConfig.THOAT,
                                                      UrlEn = "logoff",
                                                      Controller = "Customer",
                                                      Action = "LogOff"
                                              }
                                      };
            foreach (RouteModel item in models)
            {
                routes.MapRoute(
                                string.Format("{0}-vi",
                                        item.Name),
                        item.UrlVi,
                        new
                        {
                                controller = item.Controller,
                                action = item.Action
                        }
                        );
                //routes.MapRoute(
                //                string.Format("{0}-en",
                //                        item.Name),
                //        item.UrlEn,
                //        new
                //        {
                //                controller = item.Controller,
                //                action = item.Action
                //        }
                //        );
            }
        }

        private static void MapRouteForCart(RouteCollection routes)
        {
            List<RouteModel> models = new List<RouteModel>()
                                      {
                                              new RouteModel
                                              {
                                                      Name = "Cart-Gem-Infomation",
                                                      UrlVi = LinkConfig.GIO_HANG,
                                                      UrlEn = string.Format("{0}/check-out/cart",
                                                              AppUtil.JWELLERY_ROUTE_EN),
                                                      Controller = "Cart",
                                                      Action = "CartInfomationOfGem"
                                              },
                                              new RouteModel
                                              {
                                                      Name = "Cart-Gem-Payment",
                                                      UrlVi = LinkConfig.THANH_TOAN,
                                                      UrlEn = string.Format("{0}/check-out/thanh-toan",
                                                              AppUtil.JWELLERY_ROUTE_EN),
                                                      Controller = "Cart",
                                                      Action = "PaymentOfGem"
                                              }
                                      };
            foreach (RouteModel item in models)
            {
                routes.MapRoute(
                                string.Format("{0}-vi",
                                        item.Name),
                        item.UrlVi,
                        new
                        {
                                controller = item.Controller,
                                action = item.Action
                        }
                        );
                //routes.MapRoute(
                //                string.Format("{0}-en",
                //                        item.Name),
                //        item.UrlEn,
                //        new
                //        {
                //                controller = item.Controller,
                //                action = item.Action
                //        }
                //        );
            }
        }

        #region Wood

        private static void MapRouteForWood(RouteCollection routes)
        {
            routes.MapRoute(
                            AppUtil.WOOD_NAME,
                    AppUtil.WOOD_NAME,
                    new
                    {
                            controller = "Wood",
                            action = "Index",
                    }
                    );
            routes.MapRoute(
                           "wood-product-detail",
                   AppUtil.WOOD_NAME + "/{name}-{id}.html",
                   new
                   {
                       controller = "Wood",
                       action = "Product",
                       id = UrlParameter.Optional
                   }
                   );
            routes.MapRoute(
                            "wood-category",
                    AppUtil.WOOD_NAME+"/{name}-{id}",
                    new
                    {
                            controller = "Wood",
                            action = "Category",
                            id = UrlParameter.Optional
                    }
                    );

            routes.MapRoute(
                            "wood-sub-category",
                    AppUtil.WOOD_NAME + "/{categoryName}/{name}-{id}",
                    new
                    {
                            controller = "Wood",
                            action = "SubCategory",
                            id = UrlParameter.Optional
                    }
                    );

            
            
        }

        #endregion

        #region Gem

        private static void MapRouteForGem(RouteCollection routes)
        {
            routes.MapRoute(
                            AppUtil.GEM_NAME,
                    AppUtil.GEM_NAME,
                    new
                    {
                            controller = "Gem",
                            action = "Index",
                    }
                    );
            routes.MapRoute("gem-start-designing",
                    AppUtil.GEM_NAME+"/thiet-ke",
                    new
                    {
                            controller = "Gem",
                            action = "StartDesigning",
                    }
                    );

            routes.MapRoute(
                            "gem-design-customise",
                    AppUtil.GEM_NAME+"/thiet-ke/{designName}-{id}",
                    new
                    {
                            controller = "gem",
                            action = "DesignAndCustomise",
                            id = UrlParameter.Optional
                    }
                    );

          
        }

        #endregion

        #region Stone

        private static void MapRouteForStone(RouteCollection routes)
        {
            routes.MapRoute(
                            AppUtil.STONE_NAME,
                    AppUtil.STONE_NAME,
                    new
                    {
                            controller = "Stone",
                            action = "Index",
                    });
            routes.MapRoute(
                           "stone-product-detail",
                   AppUtil.STONE_NAME + "/{name}-{id}.html",
                   new
                   {
                       controller = "Stone",
                       action = "Product",
                       id = UrlParameter.Optional
                   }
                   );
            routes.MapRoute(
                            "stone-category",
                    AppUtil.STONE_NAME + "/{name}-{id}",
                    new
                    {
                            controller = "Stone",
                            action = "Category",
                            id = UrlParameter.Optional
                    });

            routes.MapRoute(
                            "stone-sub-category",
                    AppUtil.STONE_NAME + "/{categoryName}/{name}-{id}",
                    new
                    {
                            controller = "Stone",
                            action = "SubCategory",
                            id = UrlParameter.Optional
                    });
            
        }

        #endregion
    }
}
